import 'package:favoritecate/core/viewmodel/favor_meal_viewmodel.dart';
import 'package:favoritecate/core/viewmodel/filter_viewmodel.dart';
import 'package:favoritecate/core/viewmodel/meal_viewmodel.dart';
import 'package:favoritecate/ui/pages/filter/filter_page.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'ui/shared/app_theme.dart';
import 'core/router/FYRouter.dart';
import 'core/services/meal_request.dart';

void main() {
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (ctx) => FYFavorMealViewModel(),
        ),
        ChangeNotifierProvider(
          create: (ctx) => FYFilterViewModel(),
        ),
        ChangeNotifierProxyProvider<FYFilterViewModel,FYMealViewModel>(
            create: (ctx) => FYMealViewModel(),
            update: (ctx,filter,meal){
              meal.updateFilter(filter);
              return meal;
            }
        ),
      ],
      child:MyApp(),
    )
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: FYAppTheme.norTheme,
      initialRoute: FYRouter.initialRoute,
      routes: FYRouter.routers,
      onGenerateRoute: FYRouter.generateRoute,
      onUnknownRoute: FYRouter.unknowRoute,
    );
  }
}


class FYHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('首页',style: TextStyle(fontSize: 20),),),
      body: Text('首页'),
    );
  }
}

